package edu.zhang.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.zhang.dao.AdminDAO;
import edu.zhang.dao.NoticeDAO;
import edu.zhang.dao.TypeDAO;
import edu.zhang.po.Admin;
import edu.zhang.po.Notice;
import edu.zhang.po.Type;

@WebServlet("/Back/admin/AdminUpdated")
public class AdminUpdated extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id");
		String account = request.getParameter("account");
		String password = request.getParameter("password");
		
		Admin admin = new Admin();
		
		int parseInt = Integer.parseInt(id);
		admin.setId(parseInt);
		admin.setAccount(account);
		admin.setPassword(password);
		
		AdminDAO adminDAO = new AdminDAO();
		int i = adminDAO.update(admin);

		if (i > 0) {
			request.getRequestDispatcher("/admin/AdminController?option=list").forward(request, response);
		} else {
			response.sendRedirect("error.jsp");
		}
	}
}
